package com.hongdee.insurance.contract.controller;

import com.hongdee.insurance.contract.service.ITInsuranceCompanyContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by Liu XiaoLong
 * Date: 2017/11/10.
 * Remark:
 */
@RestController
@RequestMapping("/insurance/contract")
public class TInsuranceCompanyContractController {

    @Autowired
    private ITInsuranceCompanyContractService itInsuranceCompanyContractService;

    /**
     * @Name: 分页查询
     * @Author: Liu XiaoLong
     * @Date: 2017/11/1 10:37
     * @Remark:
     */
    @RequestMapping("/page")
    public Map page(@RequestParam(name = "uid", defaultValue = "") String uid,
                    @RequestParam(name = "token", defaultValue = "") String token,
                    @RequestParam(name = "page", defaultValue = "0") int page,
                    @RequestParam(name = "limit", defaultValue = "10") int limit,
                    @RequestBody Map queryData) throws Exception {

        Map map = itInsuranceCompanyContractService.page(uid,queryData,page,limit);
        map.put("success", true);
        map.put("msg", "查询成功");
        return map;
    }

    /**
     * @Name: 更新
     * @Author: Liu XiaoLong
     * @Date: 2017/11/10 17:05
     * @Remark:
     */
    @RequestMapping("/update")
    public Map update(@RequestParam(name = "uid", defaultValue = "") String uid,
                    @RequestParam(name = "token", defaultValue = "") String token,
                    @RequestBody Map queryData) throws Exception {

        Map map = itInsuranceCompanyContractService.update(uid,queryData);
        map.put("success", true);
        map.put("msg", "查询成功");
        return map;
    }

    @RequestMapping("/start")
    public Map start(@RequestParam(name = "uid", defaultValue = "") String uid,
                      @RequestParam(name = "token", defaultValue = "") String token,
                      @RequestParam(name = "id", defaultValue = "") String id) throws Exception {

        Map map = itInsuranceCompanyContractService.start(uid,id);
        map.put("success", true);
        map.put("msg", "查询成功");
        return map;
    }
    @RequestMapping("/stop")
    public Map stop(@RequestParam(name = "uid", defaultValue = "") String uid,
                      @RequestParam(name = "token", defaultValue = "") String token,
                      @RequestParam(name = "id", defaultValue = "") String id) throws Exception {

        Map map = itInsuranceCompanyContractService.stop(uid,id);
        map.put("success", true);
        map.put("msg", "查询成功");
        return map;
    }

    @RequestMapping("/info")
    public Map info(@RequestParam(name = "uid", defaultValue = "") String uid,
                    @RequestParam(name = "token", defaultValue = "") String token,
                    @RequestParam(name = "id", defaultValue = "") String id) throws Exception {

        Map map = itInsuranceCompanyContractService.info(uid,id);
        map.put("success", true);
        map.put("msg", "查询成功");
        return map;
    }
}
